package cn.iocoder.yudao.hires.controller.admin.notice.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.hires.entity.NoticeApplicationDO;
import cn.iocoder.yudao.hires.service.notice.NoticeApplicationService;
import cn.iocoder.yudao.hires.vo.NoticeApplicationRespVO;
import cn.iocoder.yudao.hires.vo.noticeapplication.NoticeApplicationSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 下游-投递记录")
@RestController
@RequestMapping("/app/notice-application")
@Validated
public class AppNoticeApplicationController {

    @Resource
    private NoticeApplicationService noticeApplicationService;


    @GetMapping("/get")
    @Operation(summary = "面试投递详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    //@PreAuthorize("@ss.hasPermission('system:notice-application:query')")
    public CommonResult<NoticeApplicationRespVO> getNoticeApplication(@RequestParam("id") Long id) {
        NoticeApplicationDO noticeApplication = noticeApplicationService.getNoticeApplication(id);
        return success(BeanUtils.toBean(noticeApplication, NoticeApplicationRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "面试投递记录")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-application:query')")
    public CommonResult<List<NoticeApplicationDO>> getNoticeApplicationList(Integer positionId, String positionName, Long userId, Long tenantId, Integer status) {
        return success(noticeApplicationService.getNoticeApplicationMySelfList(positionId, positionName, tenantId, userId, status));
    }

    @PostMapping("/create")
    @Operation(summary = "添加面试投递")
    //@PreAuthorize("@ss.hasPermission('system:notice-application:create')")
    public CommonResult<String> createNoticeApplication(@Valid @RequestBody NoticeApplicationSaveReqVO createReqVO) {
        return success(noticeApplicationService.createNoticeApplication(createReqVO));
    }
    @PostMapping("/createList")
    @Operation(summary = "添加面试投递")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-application:create')")
    public CommonResult<String> createNoticeApplicationList(@Valid @RequestBody NoticeApplicationSaveReqVO createReqVO) {
        return success(noticeApplicationService.createNoticeApplicationList(createReqVO));
    }

}